package PolymorphicHomeworkTest5;
/*
正方形类
 */
public class Square extends Graph {
    private double side;

    public Square(){

    }

    public Square(String color,boolean fill,double side){
        super(color,fill);
        this.side = side;
    }

    public double getSide() {
        return side;
    }

    public void setSide(double side) {
        this.side = side;
    }

    @Override
    public String toString() {
        return "正方形{" + "边长=" + side + " 颜色=" + super.getColor()
                +(super.isFill() ? " 填充":" 无填充") + '}';
    }

    public void getArea(){                     //重写父类抽象方法，获取面积
        double area = this.side * this.side;
        System.out.println("正方形面积是"+area);
    }

    public void getPerimeter(){                //重写父类抽象方法，获取周长
        double perimeter = 4 * this.side;
        System.out.println("正方形周长是"+perimeter);
    }

}
